home *** CD-ROM | disk | FTP | other *** search
/ Enter 2002 November / EnterCD 11_2002.iso / Internet / Amaya 6.4 / Windows NT.exe / _SETUP.1 / Transform.html < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-13  |  9.0 KB  |  232 lines

  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6.   <meta name="GENERATOR" content="amaya 6.2, see http://www.w3.org/Amaya/" />
  7.   <title>Using the HTML.trans File</title>
  8.   <style type="text/css">
  9.   </style>
  10.   <link href="style.css" rel="stylesheet" type="text/css" />
  11. </head>
  12.  
  13. <body xml:lang="en" lang="en">
  14.  
  15. <table border="0" summary="toc">
  16.   <tbody>
  17.     <tr>
  18.       <td><p><img alt="W3C" src="../images/w3c_home" /> <img alt="Amaya"
  19.         src="../images/amaya.gif" /></p>
  20.       </td>
  21.       <td><p><a href="editing_documents/about_merging_elements.html"
  22.         accesskey="p"><img alt="previous" src="../images/left.gif" /></a> <a
  23.         href="Changing.html" accesskey="t"><img alt="top"
  24.         src="../images/up.gif" /></a></p>
  25.       </td>
  26.     </tr>
  27.   </tbody>
  28. </table>
  29.  
  30. <div id="page_body">
  31. <h1>Using the HTML.trans File</h1>
  32.  
  33. <p>This document is an introduction to the structure transformation mechanism
  34. provided by <strong>Amaya</strong>. It describes the syntax of the
  35. transformation language and the way transformations are performed in the
  36. editor.</p>
  37.  
  38. <p>The file <code>amaya/HTML.trans</code> contains the description of
  39. available transformations. This file can be edited during an
  40. <strong>Amaya</strong> session. It is dynamically parsed when the
  41. transformation procedure is called by the editor,so new transformations can
  42. be added during an editing session.</p>
  43.  
  44. <p><strong>Warning</strong>: As the description of transformations may
  45. contain tags, do<strong>not</strong>edit the <code>HTML.trans</code> file
  46. with <strong>Amaya</strong>. You can use any text editor.</p>
  47. <hr />
  48.  
  49. <h2>Syntax of the Amaya transformation language</h2>
  50.  
  51. <p>Comments begin with<code><strong>!</strong></code>and continue until the
  52. end of the line.</p>
  53.  
  54. <p>The file consists of a list of transformation descriptions. Each
  55. transformation is described by three parts :</p>
  56. <ul>
  57.   <li>a <em>name</em>terminated by a colon
  58.   <strong><code>:</code></strong></li>
  59.   <li>a <em>source pattern</em> terminated by a semi-colon
  60.     <strong><code>;</code></strong></li>
  61.   <li>and a list of <em>rules</em> between braces <strong><code>{
  62.     }</code></strong> , each rule terminated by a semi-colon
  63.     <strong><code>;</code></strong></li>
  64. </ul>
  65.  
  66. <p>The name appears in the <strong>Transform</strong> menu and identifies the
  67. transformation for the end-user.</p>
  68.  
  69. <h3>The pattern</h3>
  70.  
  71. <p>The pattern describes a specific organization of the elements to be
  72. transformed. It acts as a filter over the HTML dtd. The purpose of the
  73. pattern is to identify a particular combination of elements to which the
  74. transformation can be applied. In a pattern it is possible to express
  75. conditions on sequence of tags, on the content of a tag and on the existence
  76. and value of attributes.</p>
  77.  
  78. <p>Formally, a pattern contains HTML tags (possibly with attributes) and some
  79. composition operators:</p>
  80.  
  81. <p><strong><code>|</code></strong>for choice</p>
  82.  
  83. <p><strong><code>,</code></strong>for sibling</p>
  84.  
  85. <p><strong><code>+</code></strong>for sequence</p>
  86.  
  87. <p><strong><code>?</code></strong>for option</p>
  88.  
  89. <p><strong><code>( )</code></strong> for grouping nodes</p>
  90.  
  91. <p>The braces <code><strong>{</strong></code> <code><strong>}</strong></code>
  92. define the content of a node.</p>
  93.  
  94. <p>The symbol <strong><code>*</code></strong> is a token that matches any
  95. element type.</p>
  96.  
  97. <p>It is possible to rename a tag by preceding it with a name followed by a
  98. colon (<strong><code>:</code></strong>).</p>
  99.  
  100. <p>The tag may have attributes. If no value is given for an attribute, an
  101. element is matched if the attribute is present. If a value is specified for
  102. the attribute, an element is matched if the attribute is present and have the
  103. specified value.</p>
  104.  
  105. <p><a href="#L235">Examples</a>of patterns are given at the end of the
  106. document.</p>
  107.  
  108. <h3>The rules</h3>
  109.  
  110. <p>A rule expresses how some elements identified in the pattern are
  111. transformed. A rule has two parts separated by the symbol
  112. <strong><code>></code></strong>:</p>
  113. <ul>
  114.   <li>a source tag or a name defined in the pattern,</li>
  115.   <li>a target tag list, giving the tags to be generated, and the place where
  116.     they are inserted when transforming the source element.</li>
  117. </ul>
  118.  
  119. <p>The target tag list is itself divided into two parts separated by a colon
  120. (<strong><code>:</code></strong>):</p>
  121. <ul>
  122.   <li>the generation location path (identifies the place where new tags have
  123.     to be inserted)</li>
  124.   <li>the list of tags to be generated</li>
  125. </ul>
  126.  
  127. <p>The generation location path is searched in the leftmost branch of the
  128. document tree, starting from the parent of the element matching the highest
  129. symbol of the pattern.</p>
  130.  
  131. <p>In the target tag list, the dot symbol (<code><strong>.</strong></code>)
  132. is used for descending in the tree structure.</p>
  133.  
  134. <p>If the special token star (<code><strong>*</strong></code>) ends the list
  135. of tags to be generated, the source element tag is not changed, but it can be
  136. moved to a different place in the destination.</p>
  137.  
  138. <p>If the source tag or the name in the left part of a rules is present more
  139. than once in the pattern, the rule transforms all the elements matching an
  140. occurrence of the tag in the pattern.</p>
  141. <hr />
  142.  
  143. <h2>Transformation process</h2>
  144.  
  145. <p>When the user chooses the <strong>Transform</strong> command from the
  146. <strong>Types</strong> menu, Amaya parses the <code>HTML.trans</code> file.
  147. Then the selected elements are matched with the pattern of each
  148. transformation. The names of the matched transformations are proposed to the
  149. user in a pop-up menu.</p>
  150.  
  151. <p>If several transformations with the same name match the selected elements,
  152. the higher-level matching transformation is proposed to the user. If several
  153. transformations match at the same level, the first one declared in the
  154. <code>HTML.trans</code> file is proposed. As a consequence, it is recommended
  155. to specify the transformations with specific patterns before the more general
  156. ones.</p>
  157.  
  158. <p>Once a transformation has been chosen by the user, the destination
  159. structure is built according to the rules while selected elements are
  160. traversed.</p>
  161.  
  162. <p>Finally, the contents of the source elements (text and pictures, but also
  163. structured elements) are moved into the produced elements.</p>
  164.  
  165. <p>This transformation process for HTML documents is fully described in <a
  166. href="http://opera.inrialpes.fr/opera/papers9696.html"><em>Interactively
  167. Restructuring HTML Documents</em></a>, a paper presented at the <a
  168. href="http://www5conf.inria.fr/">5th international WWW conference</a> in
  169. Paris, May 96, by CΘcile Roisin and StΘphane Bonhomme.</p>
  170. <hr />
  171.  
  172. <h2><a name="L235" id="L235">Examples</a></h2>
  173. <ul>
  174.   <li>The first example merges several consecutive unnumbered lists (UL) into
  175.     an unique list. 
  176.     <pre>Merge Lists: (UL{LI+})+;
  177.     { 
  178.     LI > UL:LI; 
  179.     }</pre>
  180.     <p>The pattern matches a sequence of unnumbered lists (UL), that contain
  181.     a sequence of items (LI).</p>
  182.     <p>The rule expresses that each time an item is encountered when
  183.     traversing the matched elements, a new LI tag is created within an UL.
  184.     When the rule is first applied, the resulting structure is empty, so
  185.     there is no UL element in which the LI can be created. Therefore an UL is
  186.     first created, then the rule can be applied.</p>
  187.   </li>
  188.   <li>The second example transforms a definition list into a table. 
  189.     <pre>Table: DL{(DT|DD)+}; 
  190.    { 
  191.    DT > <TABLE border=1>.TBODY:TR.TD; 
  192.    DD > <TABLE border=1>.TBODY.TR:TD; 
  193.    }</pre>
  194.     <p>The pattern matches any Definition List element (DL).</p>
  195.     <p>The rules explain how the table is incrementally built when the
  196.     structure of the selected definition list is traversed :</p>
  197.     <ul>
  198.       <li>Each DT involves the creation of a new row (TR) in the table
  199.       body.</li>
  200.       <li>Each DD involves the creation of a new cell (TD) in the last
  201.         existing row of the table. 
  202.         <p></p>
  203.       </li>
  204.     </ul>
  205.   </li>
  206.   <li>The third example removes a table element, keeping its content
  207.     unchanged but extracted from the table. 
  208.     <pre>Remove Table:
  209. TABLE{?CAPTION,?(body:*{(TR{(TD{(?cell_content:*)+}|
  210.                              TH{(?cell_content:*)+}
  211.                            )})+})+};
  212.      { 
  213.      CAPTION>H3; 
  214.      cell_content>:*;
  215.      }</pre>
  216.     <p>The pattern matches any table and identifies the content of each cell
  217.     of the table (cell_content).</p>
  218.     <p>The second rule expresses that the contents of each cell have to be
  219.     moved to the place of the original table.</p>
  220.   </li>
  221.   <li>See the file <kbd>amaya/HTML.trans</kbd> for more transformation
  222.     examples.</li>
  223. </ul>
  224. </div>
  225. <hr />
  226. <address>
  227.   <a href="mailto:Stephane.Bonhomme@inrialpes.fr">StΘphane Bonhomme</a> <br />
  228.   $Date: 2002/09/10 07:07:21 $
  229. </address>
  230. </body>
  231. </html>
  232.